﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using DBManager.DanhMucHeThong.BAL;

namespace MamNonTuoiTho.Form.DanhMucHeThong
{
    public partial class frmGiaoVien : DevComponents.DotNetBar.Office2007Form
    {
        public frmGiaoVien()
        {
            InitializeComponent();
            GiaoVien_Load();
        }

       
        #region LoadData
        private void GiaoVien_Load()
        {
            grvGiaoVien.AutoGenerateColumns = false;
            grvGiaoVien.DataSource = DanhMuc_BAL.DanhMuc_GetItems("GiaoVien");
        }
        #endregion LoadData
        #region Control Handler
        private void cmdThem_Click(object sender, EventArgs e)
        {
            try
            {
                frmGiaoVien_Edit GiaoVien_Edit = new frmGiaoVien_Edit();
                GiaoVien_Edit.FormClosed += new FormClosedEventHandler(GiaoVien_Edit_FormClosed);
                GiaoVien_Edit.Show();
            }
            catch (Exception)
            {
                throw;
            }
        }

        void GiaoVien_Edit_FormClosed(object sender, FormClosedEventArgs e)
        {
            GiaoVien_Load();
        }

        private void cmdChinhSua_Click(object sender, EventArgs e)
        {
            try
            {
                int DanhMucID = int.Parse(grvGiaoVien.SelectedRows[0].Cells["DanhMucID"].Value.ToString());
                frmGiaoVien_Edit GiaoVien_Edit = new frmGiaoVien_Edit();
                GiaoVien_Edit.DanhMucID = DanhMucID;
                GiaoVien_Edit.Huyen_Load();
                GiaoVien_Edit.FormClosed += new FormClosedEventHandler(GiaoVien_Edit_FormClosed);
                GiaoVien_Edit.Show();
            }
            catch (Exception)
            {
                
                throw;
            }
        }

        private void cmdXoa_Click(object sender, EventArgs e)
        {
            int DanhMucID = int.Parse(grvGiaoVien.SelectedRows[0].Cells["DanhMucID"].Value.ToString());
            DialogResult result = MessageBoxEx.Show("Bạn muốn xoá mục này?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
            if (result == DialogResult.Yes)
            {
                DanhMuc_BAL.DanhMuc_Delete(DanhMucID);
                GiaoVien_Load();
            }
        }
        #endregion Control Handler
        #region Function

        #endregion Function
    }
}